#include <iostream>
#include <string>
#include <vector>

using namespace std;

// id并不需要计算求解，可以直接流程控制获得

class Solution
{
public:
    string convert(string s, int numRows)
    {
        if (numRows == 1)
            return s;
        vector<string> ss(numRows);
        int partialSize = numRows * 2 - 2;
        for (int i = 0; i < s.size(); i++)
        {
            int id = i % partialSize;
            if (id >= numRows)
            {
                id = 2 * numRows - id -2;
            }
            ss[id].push_back(s[i]);
        }
        string result;
        for (const string &s : ss)
        {
            result.append(s);
        }
        return result;
    }
};

int main()
{
    cout << "Code6" << endl;
    Solution s;
    string str = "PAYPALISHIRING";
    cout << s.convert(str, 3);
    return 0;
}
//PAHNAPLSIIGYIR
//PAHNALIGYPISRI
//PAHNAPLSIIGYIR